/** 
Copyright (c) 2010, Sheikh Abdul Wahid Ahmed
Details @ http://extremecodeworld.codeplex.com/license
**/

using System;

namespace EXtremecode.Common.Security
{
	/// <summary>
	/// Summary description for IUser.
	/// </summary>
	public interface IUser
	{
		IRole[] Roles
		{
			get;
		}
    
		bool IsUserAuthorizedForModule(string key);
		string UserName
		{
			get;
		}
		string UserId
		{
			get;
		}
		IRole DefaultRole
		{
			get;
		}

		bool ChangePassword(string currentPassword, string newPassword);
		
	}

    public class DummyUser:IUser
    {

        #region IUser Members

        private IRole[] roles = null;
        public IRole[] Roles
        {
            get
            {
                if (roles == null)
                {
                    roles = new DummyRole[] { new DummyRole() };
                }
                return roles;
            }
        }

        public bool IsUserAuthorizedForModule(string key)
        {
            return true;
        }

        public string UserName
        {
            get {return "Guest"; }
        }

        public string UserId
        {
            get { return "DummyUser"; }
        }

        
        public IRole DefaultRole
        {
            get { return Roles[0]; }
        }

        public bool ChangePassword(string currentPassword, string newPassword)
        {
            throw new NotImplementedException("DummyUser doesnt support this method");
        }

        #endregion
    }
}
